package com.linklee.Chapter3;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class review20190106 {


    public static void main(String[]agrs){
        List<String> duoXing = Stream.of("a","b","c").collect(Collectors.toList());

        // 惰性求值
        duoXing.stream().filter(string->{
            System.out.println("string======"+string);
            return "a".equals(string);
        });

        // 早求值
        long count = duoXing.stream().filter(string->{
            System.out.println("string======"+string);
            return "a".equals(string);
        }).count();

        List<String> numicStrs = Stream.of("1","2","3").collect(Collectors.toList());

        // 更换list类型
        List<Integer> numberlist = numicStrs.stream()
                .map(string->Integer.parseInt(string))
                .collect(Collectors.toList());
        // 对原有的信息进行一部分处理
        List<String> lowwerCaseLists = Stream.of("a","b","c")
                .collect(Collectors.toList());
        List<String> upperCaseList = lowwerCaseLists.stream()
                .map(string->string.toUpperCase())
                .collect(Collectors.toList());

        // 函数风格的过滤
        List<String> allList = Stream.of("1asdasd","23asdasdad","asdaasd")
                .collect(Collectors.toList());
        List<String> startWithNumber = allList.stream()
                .filter(string->Character.isDigit(string.charAt(0)))
                .collect(Collectors.toList());

        List<String> lowwerCaseStrings = Stream.of("a","b","c")
                .collect(Collectors.toList());
        List<String> upperCaseStrings = Stream.of("A","B","C")
                .collect(Collectors.toList());

        List<String> allStrs = Stream.of(
                lowwerCaseStrings,
                upperCaseStrings
        ).flatMap(stringStream -> stringStream.stream())
                .collect(Collectors.toList());


        // 求最大最小值

        List<String> maxList = Stream.of("123123","a","b").collect(Collectors.toList());

        String maxString = maxList.stream().max(Comparator.comparing(
                string->{
                    return string.length();
                }
        )).get();

        String minString = maxList.stream().min(
                Comparator.comparing(
                        string->{
                            return string.length();
                        }
                )
        ).get();

        String s1 = "";


    }
}
